export const KnowledgeSetInfo = {
  data() {
    return {
      eduIdArr: [], //思政元素集合
    };
  },
  computed: {
    educationList: function() {
      return function(data) {
        if (
          data.ideologicalEducationList &&
          data.ideologicalEducationList.length > 0
        ) {
          return data.ideologicalEducationList
            .filter((v) => v && v.hasOwnProperty('name'))
            .map((v) => v.name)
            .toString();
        } else {
          return "暂无数据";
        }
      };
    },
  },
  methods: {
    setEduId(v) {
      this.eduIdArr = v;
    },
    //设置扩展字段
    setExtend() {
      this.form.field1 = "";
      this.form.field2 = "";
      this.form.field3 = "";
      this.extendForm.forEach((v, i) => {
        if (v.name && v.content) {
          this.form["field" + (i + 1)] = JSON.stringify(v);
        }
      });
    },
    //设置思政元素
    setEducationList() {
      this.form.sysKnowledgeEduList = [];
      if (!this.eduIdArr) return;
      this.eduIdArr.forEach((v) => {
        let obj = {
          eduId: v,
          courseId: this.$store.getters.courseId,
          courseType: this.$store.getters.libraryType,
        };
        this.form.sysKnowledgeEduList.push(obj);
      });
    },
  },
};
